﻿<!DOCTYPE html>
<html>
<head>
    <title>Supply</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link  href="<?php echo base_url();?>css/admin.css" rel="stylesheet" type="text/css" />

	<!-- 1. Add these JavaScript inclusions in the head of your page -->
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/highcharts.js"></script>
		
		<!-- 1a) Optional: add a theme file -->
		<!--
			<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/themes/gray.js"></script>
		-->
		
		<!-- 1b) Optional: the exporting module -->
		<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/modules/exporting.js"></script>
		
		
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->
		<script type="text/javascript">
		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container'
					},
					title: {
						text: 'Summary of Supplies '+<?php echo $yearsummary;?>
					},
					subtitle: {
						<?php
							if($graphoption == 'summary-pay'){
								echo "text: 'ราคาวัตถุดิบที่รับซื้อ'";
							}else if($graphoption == 'summary-wg'){
								echo "text: 'น้ำหนักวัตถุดิบที่รับซื้อ'";
							}
						?>
						//text: 'An example of irregular time data in Highcharts JS'	
					},
					xAxis: {
						categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
					},
					yAxis: {
						title: {
							<?php
								if($graphoption == 'summary-pay'){
									echo "text: 'ราคาวัตถุดิบที่รับซื้อ (บาท)'";
								}else if($graphoption == 'summary-wg'){
									echo "text: 'น้ำหนักวัตถุดิบที่รับซื้อ (กิโลกรัม)'";
								}
							?>
							//text: 'Snow depth (m)'
						},
						min: 0
					},
					tooltip: {
						formatter: function() {
							var s;
							if (this.point.name) { // the pie chart
								s = ''+
									this.point.name +': '+ this.y;
							} else {
								s = ''+
								this.series.name +': '+ this.x  +': '+ this.y;
							}
							return s;
						}
					},
					
					series: [
	<?php
		$sumtoavg = array(0,0,0,0,0,0,0,0,0,0,0,0);
		foreach ($dat as $larnname => $arr):
	?>	{
			type: 'column',
			name: '<?=$larnname;?>',
			
			data: [
			<?php 
			for($i=0;$i<12;$i++){
				echo $arr[$i].',';
				$sumtoavg[$i] += $arr[$i];
			}

			?>
			
			],
			color: '<?php echo $poscolor[$larnname];?>'
		},
	<?php	
		endforeach;
	?>
					
					 {
						type: 'spline',
						name: 'Average',
						data: [
							<?php 
							for($i=0;$i<12;$i++){
								echo $sumtoavg[$i] / $pos_count.',';	
							}
					
							?>
						],
						color: '#000000'
					}, {
						type: 'pie',
						name: 'Total consumption',
						data: [
							<?php
								$sumtoavg = array(0,0,0,0,0,0,0,0,0,0,0,0);
								foreach ($dat as $larnname => $arr):
							?>	{
									name: '<?=$larnname;?>',
									y: <?=array_sum($arr);?>,
									color: '<?php echo $poscolor[$larnname];?>'
								},
							<?php	
								endforeach;
							?>
						],
						center: [150, 40],
						size: 100,
						showInLegend: false,
						dataLabels: {
							enabled: false
						}
					}]
				});
				
				
			});
				
		</script>
</head>
<body>

 <div id="contentright">
        <div id="search">
          <div id="searchblank">
            <div id="searchinput">
             Welcome, admin
            </div>
          
            <div id="advancesearch"><a href="<?php echo site_url('login/logout');?>" class="advancesearch">Logout</a></div>
          </div>
        </div>
        </div>
    <div id="main">
       <?php 
        $menu['nowmenu'] = 'supplies';
        $this->load->view('common/divheader',$menu);
        ?>
        <div id="middle">
        <div id="breadcrumbs"><a href="dashboard.html">Dashboard</a>/ Supplies</div>
            <?php $this->load->view('manager/divleftmenu');?>
            <div id="center-column">
            <h1>Supply-Summary</h1>
                 <div class="top-bar">
                <ul id="top-selector">
                <li><a href="<?php echo site_url('manager/realtime');?>">Realtime</a></li>
                <li><a href="<?php echo site_url('manager/summary');?>">Summary</a></li>
               <li><a href="<?php echo site_url('manager/range');?>">Range</a></li>
            
            </ul>
                    
            </div>
                <div class="select-bar">
                    <p>
                      <a href="<?php echo site_url('manager/summary/summary-pay')?>">ราคารับซื้อ</a>|
                      <a href="<?php echo site_url('manager/summary/summary-wg')?>">ปริมาณรับซื้อ</a>
                    </p>
              </div>
              <div>
              		<form action="<?php echo site_url('manager/summary/'.$graphoption);?>">
              		<input type="text" name="yearsummary" value="<?php echo $yearsummary;?>" />
              		<input type="submit" value="go" />
              		</form>
              </div>
              
              <p><div id="container" style="width: 700px; height: 400px; margin: 0 auto"></div></p>
              
              <div class="table">
                    <table class="listing" cellpadding="0" cellspacing="0">
                        <thead>
    		<tr>
    			<th>ลาน</th>
    			<th>Jan</th>
    			<th>Feb</th>
    			<th>Mar</th>
    			<th>Apr</th>
    			<th>May</th>
    			<th>Jun</th>
    			<th>Jul</th>
    			<th>Aug</th>
    			<th>Sep</th>
    			<th>Oct</th>
    			<th>Nov</th>
    			<th>Dec</th>
    		</tr>
    	</thead>
                        <tbody>
    		<?php 
    			foreach ($dat as $larnname => $monthsarr):
    		?>
    				<tr>
    					<td><?php echo $larnname;?> </td>
    					<?php 
    						foreach ($monthsarr as $monthvalue):
    					?>
    					<td><?php echo $monthvalue;?></td>
    					<?php 
    						endforeach;
    					?>
    				</tr>
    		<?php 	
    			endforeach;
    		?>
    	
    	</tbody>
                    </table>
                    
              </div>
            </div>
            <div id="right-column">
                <strong class="h">Quick Link</strong>
                <div class="box">This is your admin home page. It will give you access to all things within the back end system that you will need to facilitate a smooth operation.</div>
            </div>
        </div>
        <div id="footer"><p>ALL RIGHTS RESERVED 2012 <a href="http://www.ubonbioethanol.com">UBON BIO ETHANOL CO., LTD.</a><br>Developed by DASH CO., LTD (2011-2012).  </p></div>
    </div>
</body>
</html>